<template>
  <div id="" name="">
    <van-nav-bar
        title="标题"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
    />
    <van-form @submit="onSubmit">
      <van-field
          v-model="username"
          name="用户名"
          label="用户名"
          placeholder="用户名"
          :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
          v-model="password"
          type="password"
          name="密码"
          label="密码"
          placeholder="密码"
          :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit" @click="onSubmit">提交</van-button>
      </div>
    </van-form>
  </div>
</template>
<script>
export default {
  name: '',
  props: {},
  data() {
    return {
      username: '',
      password: ''
    };
  },
  // 子组件转换
  components: {},
  // 数据引入
  mounted() {
  },
  created() {
  },
  //点击函数事件
  methods: {
    onClickLeft() {
      this.$router.back()
    },
    onSubmit() {
      if (!this.username || !this.password) {
        alert('请填写用户名密码')
        this.username = ''
        this.password = ''
      }else{
        alert('登录成功')
        localStorage.setItem('token',this.username)
        this.$router.push('/mine')
        this.username = ''
        this.password = ''
      }
    }
  },
  //计算事件
  computed: {},
  //数据监听
  watch: {},
  //过滤器
  filters: {},
  //设定自定义指令
  directives: {},
}
</script>
<style lang="scss" scoped>

</style>